<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑用户</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .navbar { box-shadow: 0 2px 4px rgba(0,0,0,.1); }
        .form-container { max-width: 600px; margin: 0 auto; }
        .footer { background-color: #f8f9fa; padding: 1rem 0; margin-top: 2rem; }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <div class="container">
            <a class="navbar-brand" href="/">
                <i class="bi bi-people-fill"></i> 用户管理系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/user/list">
                            <i class="bi bi-list-ul"></i> 用户列表
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <div class="container mt-4">
        <div class="form-container">
            <h2 class="mb-4">
                <#if user?? && user.id??>
                    <i class="bi bi-person-pencil"></i> 编辑用户
                <#else>
                    <i class="bi bi-person-plus"></i> 添加用户
                </#if>
            </h2>
            
            <form action="/user/save" method="post" class="card p-4">
                <#if user?? && user.id??>
                    <input type="hidden" name="id" value="${user.id}">
                </#if>
                
                <div class="mb-3">
                    <label for="username" class="form-label">
                        <i class="bi bi-person"></i> 用户名
                    </label>
                    <input type="text" class="form-control" id="username" name="username" 
                           value="${(user.username)!''}" required>
                </div>
                
                <div class="mb-3">
                    <label for="password" class="form-label">
                        <i class="bi bi-key"></i> 密码
                    </label>
                    <input type="password" class="form-control" id="password" name="password" 
                           <#if user?? && user.id??>required</#if>>
                    <#if user?? && user.id??>
                        <div class="form-text text-muted">
                            <i class="bi bi-info-circle"></i> 如果不修改密码，请留空
                        </div>
                    </#if>
                </div>
                
                <div class="mb-3">
                    <label for="email" class="form-label">
                        <i class="bi bi-envelope"></i> 邮箱
                    </label>
                    <input type="email" class="form-control" id="email" name="email" 
                           value="${(user.email)!''}" required>
                </div>
                
                <div class="d-flex justify-content-between mt-4">
                    <a href="/user/list" class="btn btn-secondary">
                        <i class="bi bi-arrow-left"></i> 返回
                    </a>
                    <button type="submit" class="btn btn-primary">
                        <i class="bi bi-save"></i> 保存
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- 页脚 -->
    <footer class="footer">
        <div class="container text-center">
            <p class="mb-0">© 2024 用户管理系统. All rights reserved.</p>
        </div>
    </footer>

    <script src="/static/js/bootstrap.bundle.min.js"></script>
</body>
</html> 